package com.sicheng.lc.周赛.分类.模拟;

import java.util.HashMap;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/14 20:22
 */
public class 替换数组中的元素 {
    //https://leetcode.cn/problems/replace-elements-in-an-array/
    public int[] arrayChange(int[] nums, int[][] operations) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i], i);
        }

        for (int[] operation : operations) {
            int index = map.get(operation[0]);
            nums[index] = operation[1];
            map.put(operation[1], index);
        }
        return nums;
    }
}
